from toee import *

from utilities import *
from py00439script_daemon import record_time_stamp, get_v, set_v, tsc, within_rect_by_corners

def san_dialog( attachee, triggerer ):
	if (not attachee.has_met( triggerer )):
		record_time_stamp(516)
		triggerer.begin_dialog( attachee, 1 )
	else:
		triggerer.begin_dialog( attachee, 280 )
	return SKIP_DEFAULT

def san_dying( attachee, triggerer ):
	game.global_flags[106] = 1
	record_time_stamp(458)
	return RUN_DEFAULT

def san_resurrect( attachee, triggerer ):
	game.global_flags[106] = 0
	return RUN_DEFAULT

def san_enter_combat( attachee, triggerer ):
	game.global_flags[346] = 0
	return RUN_DEFAULT

def san_first_heartbeat( attachee, triggerer ):
	if (attachee.leader_get() == OBJ_HANDLE_NULL) and not game.combat_is_active():
		game.global_vars[715] = 0
	return RUN_DEFAULT
def escort_below( attachee, triggerer ):
	# game.global_flags[144] = 1
	game.global_vars[691] = 2
	game.fade_and_teleport(0,0,0,5080,478,451)
	return RUN_DEFAULT

def is_safe_to_talk2(speaker,listener, radius):
	if (speaker.can_see(listener)):
		if (speaker.distance_to(listener) <= radius):
			return 1
	return 0
